<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>侦听属性</title>
	<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
	<div id="demo">
		<p>{{fullName}}</p>
		<p>{{fullName2}}</p>
		


	</div>
	<script type="text/javascript">
		var vm = new Vue({
			el:'#demo',
			data:{
				firstName:'张',
				lastName:'三',
				fullName:'张三',
				
				firstName2:'李',
				lastName2:'四'
				/*fullName:'Foo Bar'*/
			},
			watch:{
				firstName: function(val){
					this.fullName = val + this.lastName
				},
				lastName: function(val){
					this.fullName = this.firstName + val
				}
			},
			computed:{
				fullName2: function(){
					return this.firstName2 + this.lastName2
				}
			}
		})
	</script>
</body>
</html>